package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.DingBean01;
import com.lwj.liwanjia.bean.DingBean02;

import java.util.List;

/**
 * Created by 001 on 2017/10/27.
 */

public class DingAdapter01 extends RecyclerView.Adapter<DingAdapter01.ViewHolder> {

    private Context mContext;
    private List<DingBean02.DataBean.CommodityBean> mList;

    public DingAdapter01(Context mContext, List<DingBean02.DataBean.CommodityBean> mList) {
        this.mContext = mContext;
        this.mList = mList;
    }

    @Override
    public DingAdapter01.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_01, parent, false);

        ViewHolder holder = new ViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(DingAdapter01.ViewHolder holder, int position) {

        DingBean02.DataBean.CommodityBean bean = mList.get(position);

        Glide.with(mContext).load(bean.getCommodityimage()).into(holder.iv_photo);
        holder.tv_title.setText(bean.getCommodityname());
        holder.tv_info.setText(bean.getCommodityinfo());
        holder.tv_money.setText("¥"+bean.getCommodityprice()+"");
        holder.tv_number.setText("*"+bean.getCommodityNum());

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        ImageView iv_photo;
        TextView tv_title;
        TextView tv_info;
        TextView tv_money;
        TextView tv_number;

        public ViewHolder(View itemView) {
            super(itemView);

            iv_photo = (ImageView) itemView.findViewById(R.id.iv_photo);
            tv_title = (TextView) itemView.findViewById(R.id.tv_title);
            tv_info = (TextView) itemView.findViewById(R.id.tv_info);
            tv_money = (TextView) itemView.findViewById(R.id.tv_money);
            tv_number = (TextView) itemView.findViewById(R.id.tv_number02);
        }
    }
}
